{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from xgboost import XGBClassifier\n",
    "import xgboost as xgb\n",
    "\n",
    "import time\n",
    "\n",
    "import numpy as np\n",
    "import seaborn as sns\n",
    "import matplotlib.pyplot as plt\n",
    "import pandas as pd\n",
    "\n",
    "from sklearn.metrics import log_loss\n",
    "from sklearn.model_selection import GridSearchCV,StratifiedKFold"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "train = pd.read_csv(\"RentListingInquries_FE_train.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "y_train = train['interest_level']\n",
    "x_train = train.drop(['interest_level'],axis=1)\n",
    "x_train = np.array(x_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#准备交叉验证参数\n",
    "kfold = StratifiedKFold(n_splits=5,shuffle=True,random_state=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#第二次确定弱学习器数目，这是一个三分类的问题 [2 1 0] 为高、中、低三类。直接调用XGBoost"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "xgb1 = XGBClassifier(\n",
    "    learning_rate=0.1,\n",
    "    n_estimators=205,    #第一次确定的学习器数目\n",
    "    max_depth=7,\n",
    "    min_child_weight=5,\n",
    "    gamma=0,\n",
    "    subsample=0.3,\n",
    "    colsample_bytree=0.8,\n",
    "    colsample_bylevel=0.7,\n",
    "    objective='multi:softprob',\n",
    "    seed=3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def modelfit(xlg,x_train,y_train,cv_folds=None,early_stopping_rounds=10):\n",
    "    xgb_param = xlg.get_xgb_params()\n",
    "    xgb_param['num_class'] = 3\n",
    "\n",
    "    xgtrain = xgb.DMatrix(x_train, label=y_train)\n",
    "\n",
    "    cvresult = xgb.cv(xgb_param, xgtrain, num_boost_round=xlg.get_params()['n_estimators'], folds=cv_folds,\n",
    "                      metrics='mlogloss', early_stopping_rounds=early_stopping_rounds)\n",
    "    cvresult.to_csv('n_estimators_1.csv', index_label='n_estimators')\n",
    "\n",
    "    n_estimators = cvresult.shape[0]\n",
    "\n",
    "\n",
    "    print(\"n_estimators is \",n_estimators)\n",
    "\n",
    "    xlg.set_params(n_estimators=n_estimators)\n",
    "    xlg.fit(x_train, y_train, eval_metric='mlogloss')\n",
    "\n",
    "    cvresult = pd.DataFrame.from_csv('n_estimators_1.csv')\n",
    "\n",
    "    test_means = cvresult['test-mlogloss-mean']\n",
    "    test_stds = cvresult['test-mlogloss-std']\n",
    "\n",
    "    train_means = cvresult['train-mlogloss-mean']\n",
    "    train_stds = cvresult['train-mlogloss-std']\n",
    "\n",
    "    x_axis = range(0, cvresult.shape[0])\n",
    "\n",
    "    plt.errorbar(x_axis, test_means, yerr=test_stds, label='Test')\n",
    "    plt.errorbar(x_axis, train_means, yerr=train_stds, label=\"Train\")\n",
    "\n",
    "    plt.title(\"XGBoost n_estimators vs Log Loss\")\n",
    "    plt.xlabel('n_estimators')\n",
    "    plt.ylabel('Log Loss')\n",
    "    plt.savefig('n_estimator_1.png')\n",
    "    plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "time.struct_time(tm_year=2018, tm_mon=5, tm_mday=28, tm_hour=1, tm_min=31, tm_sec=40, tm_wday=0, tm_yday=148, tm_isdst=0)\n",
      "n_estimators is  150\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYU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9Y2bPRMsuNbN3ohi+m/H6zWZ2s5m9BhxvZt8xs5nRYC0/yM4RlbwT9y3VmjR15gSMIPSc\neWQ0/xBweTtlnwLGRM+PJfTtBKH7gcroeXn0eBVwW8Zrm+cJg6w8SOjC4HxgI3AY4UfXtIxYmrqM\nSALPAodH8wtp6QZhCKGvpApCD7BPAx+J1jlwcdO2CF05WGacmjTt66QzBdkfLXD3N6Pn0wiJYgdR\nd+UnAH8wszeBXwBNg528BNxrZp8kfIF3xF/d3QkJZaWHTtHSwIyM/V9sZtOBNwijg7U1+t/RwLMe\nelRt6hb6lGhdI6FHXQiJZzvwSzO7ENi605ZE9kJq90VEup3ajOeNQFvVRwnCIDdHtl7h7p82s2MJ\nI869aWY7ldnFPtOt9p8GUlGvnV8Ejnb39VG1UnEb22mrv/0m2z1qR3D3BjM7htDj6iXA9YSuzUX2\nic4UJC95GMxogZn9KzQPqH5E9HyUu7/m7l8H1hD6v98ElO3DLnsRBgDaYGYD2XGQncxtvwacamb9\no/GFLwWea72x6Eynt7s/DtxI6ClWZJ/pTEHy2ceBO8zsa0ABoV3gLeD7ZjaG8Kv9qWjZYuArUVXT\nLXu6I3d/y8zeIFQnzSdUUTW5E/ibmS139w+Y2U2EsRYMeNzd2xpnoQz4i5kVR+U+t6cxibRFl6SK\niEgzVR+JiEgzVR/Jfs/MbieMN53pVne/J454RHKZqo9ERKSZqo9ERKSZkoKIiDRTUhARkWZKCiIi\n0uz/A22Km4QOOZQzAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1b1ee436f98>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "time.struct_time(tm_year=2018, tm_mon=5, tm_mday=28, tm_hour=1, tm_min=41, tm_sec=16, tm_wday=0, tm_yday=148, tm_isdst=0)\n"
     ]
    }
   ],
   "source": [
    "print(time.localtime(time.time()))\n",
    "modelfit(xgb1, x_train, y_train, cv_folds=kfold)\n",
    "print(time.localtime(time.time()))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "### 第二次确定学习器数目为150"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
